﻿using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.HYT.Dto;
using NP.BPMReportPlatform.MaterialMasterData.Dto;
using NP.BPMReportPlatform.MaterialMasterData.Dtos;
using NP.BPMReportPlatform.RestfulApis.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;

namespace NP.BPMReportPlatform.HYT
{
    /// <summary>
    /// 回用桶收货
    /// </summary>
    //[Authorize]
    [ApiController]
    [Route("api/HYTSH")]
    public class HYTSHController : BPMReportPlatformController
    {
        public readonly IHYTSHService _service;
        public HYTSHController(IHYTSHService service)
        {
            _service = service;
        }

        [HttpPost]
        [Route("GetAllAsync")]
        public async Task<PagedResultDto<HYTSHDto>> GetAllAsync([FromBody] HYTInput input)
        {
            return await _service.GetAllAsync(input);
        }

        [HttpPost]
        [Route("ExportAsync")]
        public async Task<XlsxFileResult<HYTSHDto>> ExportAsync([FromBody] HYTInput input)
        {
            var rst = await _service.ExportAsync(input);            
            return new XlsxFileResult<HYTSHDto>(rst, "导出Excel");
        }

        [HttpPost]
        [Route("Edit")]
        public async Task<string> Edit([FromBody] HYTEditInput input)
        {
            return await _service.Eidt(input);
        }

        [HttpPost]
        [Route("ReSync")]
        public async Task<ApiResultDto> ReSync([FromBody] HYTReSyncInput input)
        {
            return await _service.ReSync(input);
        }

        [HttpPost]
        [Route("SyncRowItemFromEngine")]
        public async Task SyncRowItemFromEngine()
        {
            await _service.SyncRowItemFromEngine();
        }

        [HttpPost]
        [Route("SyncDetailOrderNumberFromHeader")]
        public async Task SyncDetailOrderNumberFromHeader()
        {
            await _service.SyncDetailOrderNumberFromHeader();
        }
    }
}
